import type { UnlistenFn } from "@tauri-apps/api/event";
import type { WorkspaceUserAgentBaseEnum } from "./workspace-base";
export enum AuthTypeEnum {
  NO_AUTH = "No Auth",
  API_KEY = "API Key",
  BEARER_TOKEN = "Bearer Token",
  BASIC_AUTH = "Basic Auth",
}

export enum AuthSectionEnum {
  HEADER = "Header",
  QUERY_PARAMETER = "Query Parameter",
  COOKIES = "Cookies",
}
export enum RequestMethodEnum {
  GET = "GET",
  POST = "POST",
  PUT = "PUT",
  DELETE = "DELETE",
  PATCH = "PATCH",
  HEAD = "HEAD",
  OPTIONS = "OPTIONS",
}
export enum SocketDataTypeEnum {
  JSON = "JSON",
  XML = "XML",
  HTML = "HTML",
  TEXT = "Text",
  JAVASCRIPT = "JavaScript",
  IMAGE = "Image",
}
export enum SocketSectionEnum {
  PARAMETERS = "Parameters",
  MESSAGE = "Message",
  HEADERS = "Headers",
  EVENTS = "Events",
}

export enum MessageTypeEnum {
  SENDER = "Sender",
  RECEIVER = "Receiver",
}

export enum ResponseFormatterEnum {
  PRETTY = "Pretty",
  RAW = "Raw",
  PREVIEW = "Preview",
  VISUALIZE = "Visualize",
}
export enum ResponseSectionEnum {
  RESPONSE = "Response",
  HEADERS = "Headers",
}

export enum RequestDatasetEnum {
  FORMDATA = "Form Data",
  URLENCODED = "URL Encoded",
  RAW = "Raw",
  NONE = "None",
}

export enum FormDataTypeEnum {
  TEXT = "text",
  FILE = "file",
}

export enum UntrackedItemsEnum {
  UNTRACKED = "UNTRACKED-",
}

export interface KeyWrapper {
  key: string;
}
export interface ValueWrapper {
  value: string;
}
export interface CheckedWrapper {
  checked: boolean;
}

export interface UrlWrapper {
  url: string;
}

export interface KeyValue extends KeyWrapper, ValueWrapper {}
export interface KeyValueChecked
  extends KeyWrapper,
    ValueWrapper,
    CheckedWrapper {}

export interface MessageLanguageWrapper {
  messageLanguage: SocketDataTypeEnum;
}
export interface RequestNavigationWrapper {
  requestNavigation: SocketSectionEnum;
}
export interface LeftSplitterWidthPercentageWrapper {
  leftSplitterWidthPercentage: 50;
}
export interface RightSplitterWidthPercentageWrapper {
  rightSplitterWidthPercentage: 50;
}
export interface IsSaveInProgressWrapper {
  isSaveInProgress: false;
}
export interface IsParameterBulkEditActiveWrapper {
  isParameterBulkEditActive: false;
}
export interface IsHeaderBulkEditActiveWrapper {
  isHeaderBulkEditActive: false;
}
export interface State
  extends MessageLanguageWrapper,
    RequestNavigationWrapper,
    LeftSplitterWidthPercentageWrapper,
    RightSplitterWidthPercentageWrapper,
    IsSaveInProgressWrapper,
    IsParameterBulkEditActiveWrapper,
    IsHeaderBulkEditActiveWrapper {}

export interface StatePartial
  extends Partial<MessageLanguageWrapper>,
    Partial<RequestNavigationWrapper>,
    Partial<LeftSplitterWidthPercentageWrapper>,
    Partial<RightSplitterWidthPercentageWrapper>,
    Partial<IsSaveInProgressWrapper>,
    Partial<IsParameterBulkEditActiveWrapper>,
    Partial<IsHeaderBulkEditActiveWrapper> {}

export interface StateWrapper {
  state: State;
}

export interface HeadersWrapper {
  headers: KeyValueChecked[];
}

export interface QueryParamsWrapper {
  queryParams: KeyValueChecked[];
}
export interface AutoGeneratedHeadersWrapper {
  autoGeneratedHeaders: KeyValueChecked[];
}

export interface MessageWrapper {
  message: string;
}

export interface EventNameWrapper {
  eventName: string;
}

export interface eventKeyWrapper {
  event: string;
}
export interface eventToggleWrapper {
  listen: boolean;
}

export interface EventsValues extends eventKeyWrapper, eventToggleWrapper {}

export interface EventsWrapper {
  events: EventsValues[];
}
export interface SocketIo
  extends QueryParamsWrapper,
    AutoGeneratedHeadersWrapper,
    StateWrapper,
    UrlWrapper,
    HeadersWrapper,
    MessageWrapper,
    EventsWrapper,
    EventNameWrapper {}

export interface SocketIoWrapper {
  socketio: SocketIo;
}
export enum SocketIORequestMessageTransmitterTabEnum {
  DISCONNECTOR = "disconnector",
  CONNECTER = "connecter",
  RECEIVER =  "receiver",
  SENDER =  "sender"
}

export enum SocketIORequestStatusTabEnum {
  CONNECTED = "connected",
  DISCONNECTED = "disconnected",
  CONNECTING =  "connecting",
  DISCONNECTING =  "disconnecting"
}

export type SocketIORequestMessageTabInterface = {
  data: string;
  transmitter: SocketIORequestMessageTransmitterTabEnum;
  timestamp: string;
  uuid: string;
};
export type SocketIORequestOutputTabInterface = {
  messages: SocketIORequestMessageTabInterface[];
  status: SocketIORequestStatusTabEnum
  agent: WorkspaceUserAgentBaseEnum,
  search: string;
  body: string;
  contentType: string;
  url: string;
  filter: "All Messages" | "Sent" | "Received";
  connectListener?: any;
  disconnectListener?: any;
  messageListener?: any;
  abortController: AbortController;
};
